from app import create_app, db
from app.models.user import User

app = create_app()

def create_admin():
    with app.app_context():
        db.create_all()
        admin = User.query.filter_by(username='admin').first()
        if not admin:
            admin = User(username='admin')
            admin.set_password('admin123')
            db.session.add(admin)
            db.session.commit()
            print('管理员用户创建成功')
        else:
            print('管理员用户已存在')

if __name__ == '__main__':
    create_admin() 